package com.java123.t10.demo.extra;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class Demo1 {

	
	public static void main(String[] args) {
		try {
		//单例模式
		Calendar cal = Calendar.getInstance();
		//日期格式化工具
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		String dateStr = "2018-10-04 00:00:00";
		Date date = sdf.parse(dateStr);
		//设置时间
		cal.setTime(date);
		//cal获取日期
		Date newDate = cal.getTime();
		//格式化日期
		System.out.println(sdf.format(newDate));
		} catch (ParseException e) {
			e.printStackTrace();
		}
	}
}
